/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package WebServices;

import Interfaces.Factory;
import Interfaces.ICtrlRelojSistema;
import java.util.Calendar;
import java.util.logging.Logger;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.ParameterStyle;
import javax.jws.soap.SOAPBinding.Style;
import javax.xml.ws.Endpoint;

/**
 *
 * @author Sebas
 */
@WebService
@SOAPBinding(style = Style.RPC, parameterStyle = ParameterStyle.WRAPPED)
public class CtrlRelojSistemaWS implements ICtrlRelojSistema{

    private Endpoint endpoint = null;
    private Logger log = Logger.getLogger(CtrlUsuariosWS.class.getName());

    @WebMethod(exclude = true)
    public void publicar() {
        Propiedades propiedades = Propiedades.getInstance();
        String camino = "http://"+propiedades.getServer()+":"+propiedades.getPuerto()+"/CtrlRelojSistema";
        log.info("publicando el endpoint CtrlRelojSistema");
        endpoint = Endpoint.publish(camino, this);
        log.info("Endpoint CtrlRelojSistema publicado en " + camino);
    }

    @WebMethod(exclude = true)
    public Endpoint getEndpoint() {
        return endpoint;
    }
    
    @Override
    @WebMethod
    public Calendar getTime() {
        ICtrlRelojSistema ctrlReloj = Factory.getInstance().getRelojSistema();
        return (ctrlReloj.getTime());
    }

    @Override
    public void setReloj(Calendar cal) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
}
